package com.mmp.main.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 * The persistent class for the hospital database table.
 *
 */
@Entity
@NamedQuery(name = "Hospital.findAll", query = "SELECT h FROM Hospital h")
public class Hospital implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	private Integer id;

	@Column(name = "bed_no")
	private Integer bedNo;

	@Column(name = "hosp_director_name")
	private String hospDirectorName;

	@Column(name = "mmd_head_name")
	private String mmdHeadName;

	@Column(name = "mmd_supervisor_name")
	private String mmdSupervisorName;

	private String name;

	private Boolean status;

	// bi-directional many-to-one association to HospitalDepatment
	@LazyCollection(LazyCollectionOption.FALSE)
	@OneToMany(mappedBy = "hospital")
	@Fetch(value = FetchMode.SUBSELECT)
	private List<HospitalDepatment> hospitalDepatments;

	// bi-directional many-to-one association to HospitalDevice
	@OneToMany(mappedBy = "hospital")
	@Fetch(value = FetchMode.SUBSELECT)
	private List<HospitalDevice> hospitalDevices;

	// bi-directional many-to-one association to HospitalOperatingCompany
	@OneToOne(mappedBy = "hospital")
	private HospitalOperatingCompany hospitalOperatingCompany;

	// bi-directional many-to-one association to User
	@OneToMany(mappedBy = "hospital")
	@Fetch(value = FetchMode.SUBSELECT)
	private List<User> users;

	public Hospital() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getBedNo() {
		return this.bedNo;
	}

	public void setBedNo(Integer bedNo) {
		this.bedNo = bedNo;
	}

	public String getHospDirectorName() {
		return this.hospDirectorName;
	}

	public void setHospDirectorName(String hospDirectorName) {
		this.hospDirectorName = hospDirectorName;
	}

	public String getMmdHeadName() {
		return this.mmdHeadName;
	}

	public void setMmdHeadName(String mmdHeadName) {
		this.mmdHeadName = mmdHeadName;
	}

	public String getMmdSupervisorName() {
		return this.mmdSupervisorName;
	}

	public void setMmdSupervisorName(String mmdSupervisorName) {
		this.mmdSupervisorName = mmdSupervisorName;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	public List<HospitalDepatment> getHospitalDepatments() {
		return this.hospitalDepatments;
	}

	public void setHospitalDepatments(List<HospitalDepatment> hospitalDepatments) {
		this.hospitalDepatments = hospitalDepatments;
	}

	public HospitalDepatment addHospitalDepatment(HospitalDepatment hospitalDepatment) {
		getHospitalDepatments().add(hospitalDepatment);
		hospitalDepatment.setHospital(this);

		return hospitalDepatment;
	}

	public HospitalDepatment removeHospitalDepatment(HospitalDepatment hospitalDepatment) {
		getHospitalDepatments().remove(hospitalDepatment);
		hospitalDepatment.setHospital(null);

		return hospitalDepatment;
	}

	public List<HospitalDevice> getHospitalDevices() {
		return this.hospitalDevices;
	}

	public void setHospitalDevices(List<HospitalDevice> hospitalDevices) {
		this.hospitalDevices = hospitalDevices;
	}

	public HospitalDevice addHospitalDevice(HospitalDevice hospitalDevice) {
		getHospitalDevices().add(hospitalDevice);
		hospitalDevice.setHospital(this);

		return hospitalDevice;
	}

	public HospitalDevice removeHospitalDevice(HospitalDevice hospitalDevice) {
		getHospitalDevices().remove(hospitalDevice);
		hospitalDevice.setHospital(null);

		return hospitalDevice;
	}

	public HospitalOperatingCompany getHospitalOperatingCompany() {
		return this.hospitalOperatingCompany;
	}

	public void setHospitalOperatingCompany(HospitalOperatingCompany hospitalOperatingCompany) {
		this.hospitalOperatingCompany = hospitalOperatingCompany;
	}

	// public HospitalOperatingCompany
	// addHospitalOperatingCompany(HospitalOperatingCompany
	// hospitalOperatingCompany) {
	// getHospitalOperatingCompanies().add(hospitalOperatingCompany);
	// hospitalOperatingCompany.setHospital(this);
	//
	// return hospitalOperatingCompany;
	// }

	// public HospitalOperatingCompany
	// removeHospitalOperatingCompany(HospitalOperatingCompany
	// hospitalOperatingCompany) {
	// getHospitalOperatingCompany().remove(hospitalOperatingCompany);
	// hospitalOperatingCompany.setHospital(null);
	//
	// return hospitalOperatingCompany;
	// }

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public User addUser(User user) {
		getUsers().add(user);
		user.setHospital(this);

		return user;
	}

	public User removeUser(User user) {
		getUsers().remove(user);
		user.setHospital(null);

		return user;
	}

}
